home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AmigActive 10
/
AACD 10.iso
/
AACD
/
Magazine
/
Online
/
httpproxy
/
deinstall.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1996-08-20
|
2KB
|
78 lines
/* Remove new installation inside files. Returns 0 on success, 20 on failure. */
/* Usage: rx deinstall.rexx CheckText/A Files/M */
/*
* A copy of every 'file' is made into 'file.rexxbackup'.
*
* All lines between ";BEGIN 'CheckText'" and ";END 'CheckText'" or
* /-*BEGIN 'CheckText'*-/ and /-*END 'CheckText'*-/ (of course without the '-'s)
* are removed.
*
* When the files cannot be opened, they are skipped.
* When a write fails or the ending statement is missing, the backup file
* is restored and the script returns 20.
*/
parse arg CheckText AllArgs
address command
do forever
parse VAR AllArgs File AllArgs
if File == "" then
leave
if ~exists(File) then /* skip not existing files */
iterate
"delete >nil: "File".rexxbackup"
"rename "File File".rexxbackup"
if (open("r",File".rexxbackup","READ") ~= 1) then
do
say "Reading file "File" failed..."
"rename "File".rexxbackup "File /* and rename back... */
exit 20
end
if (open("w",File,"WRITE") ~= 1) then
do
say "Writing to file "File" failed..."
"rename "File".rexxbackup "File /* and rename back... */
exit 20
end
do while (eof("r") = 0)
line = readln("r")
if (line == "" & eof("r") = 1) then
leave
if (~ (BeginExp(line))) then
call writeln("w",line)
else
do while (~ (EndExp(line)))
if eof("r") then
do
say "begin expression not ending with end expression"
call close("r")
call close("w")
"delete >nil: "File
"rename "File".rexxbackup "File /* and rename back... */
exit 20
end
line = readln("r")
end
end
call close("r")
call close("w")
end
exit 0
BeginExp: procedure expose CheckText
parse Arg n
if (n == ";BEGIN "CheckText) | (n == "/*BEGIN "CheckText"*/") then
return 1
return 0
EndExp: procedure expose CheckText
parse Arg n
if (n == ";END "CheckText) | (n == "/*END "CheckText"*/") then
return 1
return 0